import { createApp } from 'vue';
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import router from './router';
import App from './App.vue';
import axios from 'axios';
import VueAxios from 'vue-axios';
import BaiduMap from 'vue-baidu-map-3x';

const app = createApp(App);

axios.defaults.baseURL = process.env.VUE_APP_API_URL || 'http://localhost:81/';
axios.interceptors.request.use((config) => {
  const token = localStorage.getItem('token');
  if (token) config.headers.Authorization = `Bearer ${token}`;
  return config;
});

// 方法 2：配置 Element Plus 减少重排（推荐）
app.config.globalProperties.$ELEMENT = { size: 'small', zIndex: 3000 };

app.use(ElementPlus);
app.use(router);
app.use(BaiduMap, { ak: 'VZT4myk84rWmdKDYEFR7MaBVm0vyay0m' });
app.use(VueAxios, axios);

app.mount('#app');